// 我的发布页面

const app = getApp()
const db = wx.cloud.database()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    goodsObjects:[],
    id: "2"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getGoods()
  },

  //获取openid后查询数据库
  getGoods(){
    var that = this
    app.appGetOpenId().then(res=>{
      that.setData({
        id: res
      })
      that.getGoodsDB()
    })
  },

  //DB中获取发布的商品
  getGoodsDB(){
    var that = this
    db.collection("goods").where({
      _openid: that.data.id
    }).get().then(res=>{
      that.setData({
        goodsObjects : res.data,
      })
    })
  },

})